<?php
declare (strict_types=1);

namespace app\command;

use app\index\service\LawyerRankService;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Rank extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('rank')
            ->setDescription('the rank command');
    }

    protected function execute(Input $input, Output $output)
    {
        // 指令输出
        $output->writeln('重新生成排行榜数据开始');

        // 依次处理
        $ranks = ['professional', 'comment'];
        foreach ($ranks as $rank) {
            $this->getLawyerRankService()->rank($rank);
        }

        $output->writeln('重新生成排行榜数据结束');
    }

    private function getLawyerRankService(): LawyerRankService
    {
        return app(LawyerRankService::class);
    }
}
